<template>

  <div>
    <van-nav-bar title="我的订单" left-text="返回" left-arrow @click-left="()=>$router.go(-1)" />
    <div v-if="orderList.length>0">
      <orderStrip v-for="(item, index) in orderList" :key="index" :pieceData="item" :userID="userID" />
    </div>
    <div v-else>
      <van-empty description="您没有订单，快去下单吧~" />
    </div>
  </div>



</template>

<script>
import orderStrip from "@/components/orderStrip";

export default {
  components: {
    orderStrip
  },
  data() {
    return {
      orderList: [],
      userID: ''
    };
  },
  created() {
    this.userID = parseInt(localStorage.getItem('userID'))
    this.$axios.get(`/getMyOrder?userID=${localStorage.getItem('userID')}`).then(res => {
      if (res.code === 200) {
        this.orderList = res.data
      } else {
        Toast('获取订单失败')
      }
    })
  }
};
</script>

<style>
</style>